<template>
  <Item class="dropdown">
    <button class="dropbtn">{{ menuName }}</button>
    <div class="dropdown-content">
      <a href="#" v-for="item in menuList" :key="item.id"
         @click="$emit('selectClick',item.name)">{{ item.name }}</a>
    </div>
  </Item>
</template>

<script>
import Item from "@/components/Item";

export default {
  name: "DropDownMenu",
  components: {
    Item,
  },
  props: {
    menuName: "",
    menuList: {
      type: Array,
    },
    isShowMenu: false,
  },
  methods: {
    show() {
      this.isShowMenu = true;
    }
  }
}
</script>

<style scoped>

/* 下拉按钮样式 */
.dropbtn {
  color: black;
  padding: 16px;
  font-size: 15px;
  border: none;
  cursor: pointer;
  height: 45px;
}

/* 容器 <div> - 需要定位下拉内容 */
.dropdown {
  position: relative;
  display: inline-block;
  width: 100%;
  height: 100%;
}

/* 下拉内容 (默认隐藏) */
.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 140px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}

/* 下拉菜单的链接 */
.dropdown-content a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  font-size: 15px;
}

/* 鼠标移上去后修改下拉菜单链接颜色 */
.dropdown-content a:hover {
  background-color: #f1f1f1
}

/* 在鼠标移上去后显示下拉菜单 */
.dropdown:hover .dropdown-content {
  display: block;
}

</style>